<?php
namespace Core\Datastorage;

require_once(DATASTORAGE_DIR . 'lambdaexpression.class.php');

/**
* Expression class definition. This class manage all expression use to request database.
*
* @author Didelot Guillaume
* @version 1.0.0
* @copyright Copyright (c) 2015, Didelot Guillaume
*
* @method string SQL_EQ($leftPart, $rightPart)
* @method string SQL_SUPOREQ($leftPart, $rightPart)
* @method string SQL_SUP($leftPart, $rightPart)
* @method string SQL_INFOREQ($leftPart, $rightPart)
* @method string SQL_INF($leftPart, $rightPart)
* @method string SQL_OR($leftPart, $rightPart)
* @method string SQL_AND($leftPart, $rightPart)
*/
class Expression 
{
	/**
	* This method create an equal SQL expression ( = )
 	*	
	* @param string $leftPart The left part of the equal operator
	* @param string $rightPart The right part of the equal operator
	*
	* @return string The SQL criteria
	*/
	public static function SQL_EQ($leftPart, $rightPart)
	{
		return new LambdaExpression($leftPart, "=", $rightPart);
	}
	
	/**
	* This method create a superior or equal SQL expression ( >= )
 	*	
	* @param string $leftPart The left part of the superior or equal operator
	* @param string $rightPart The right part of the superior or equal operator
	*
	* @return string The SQL criteria
	*/
	public static function SQL_SUPOREQ($leftPart, $rightPart)
	{
		return new LambdaExpression($leftPart, ">=", $rightPart);
	}
	
	/**
	* This method create a superior SQL expression ( > )
 	*	
	* @param string $leftPart The left part of the superior operator
	* @param string $rightPart The right part of the superior operator
	*
	* @return string The SQL criteria
	*/
	public static function SQL_SUP($leftPart, $rightPart)
	{
		return new LambdaExpression($leftPart, ">", $rightPart);
	}
	
	/**
	* This method create a inferior or equal SQL expression ( =< )
 	*	
	* @param string $leftPart The left part of the inferior or equal operator
	* @param string $rightPart The right part of the inferior or equal operator
	*
	* @return string The SQL criteria
	*/
	public static function SQL_INFOREQ($leftPart, $rightPart)
	{
		return new LambdaExpression($leftPart, "<=", $rightPart);
	}
	
	/**
	* This method create a inferior SQL expression ( < )
 	*	
	* @param string $leftPart The left part of the inferior operator
	* @param string $rightPart The right part of the inferior operator
	*
	* @return string The SQL criteria
	*/
	public static function SQL_INF($leftPart, $rightPart)
	{
		return new LambdaExpression($leftPart, "<", $rightPart);
	}
	
	/**
	* This method create a OR SQL expression ( or )
 	*	
	* @param string $leftPart The left part of the or operator
	* @param string $rightPart The right part of the or operator
	*
	* @return string The SQL criteria
	*/
	public static function SQL_OR($leftPart, $rightPart)
	{
		return new LambdaExpression($leftPart, "or", $rightPart);
	}
	
	/**
	* This method create a AND SQL expression ( and )
 	*	
	* @param string $leftPart The left part of the and operator
	* @param string $rightPart The right part of the and operator
	*
	* @return string The SQL criteria
	*/
	public static function SQL_AND($leftPart, $rightPart)
	{
		return new LambdaExpression($leftPart, "and", $rightPart);
	}
}
?> 